package com.nq.activaity.controller;


import com.nq.common.ServerResponse;
import com.nq.service.IFundsApplyService;
import com.nq.service.LotteryService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

@Controller
@RequestMapping({"/user/lottery/"})
@Slf4j
public class LotteryController {


    @Resource
    private LotteryService lotteryService;


    /**
     * 奖品列表接口
     * @param httpServletRequest
     * @return
     */
    @RequestMapping(value = {"prizesList.do"}, method = {RequestMethod.POST})
    @ResponseBody
    public ServerResponse prizesList(HttpServletRequest httpServletRequest) {
        return this.lotteryService.prizesList(httpServletRequest);
    }

    /**
     * 抽奖接口
     * @param httpServletRequest
     * @return
     */
    @RequestMapping(value = {"execute.do"}, method = {RequestMethod.POST})
    @ResponseBody
    public ServerResponse reg(HttpServletRequest httpServletRequest) {
        return this.lotteryService.execute(httpServletRequest);
    }


    /**
     * 查询是否设置收货接口
     * @param httpServletRequest
     * @return
     */
    @RequestMapping(value = {"queryReceiving.do"}, method = {RequestMethod.POST})
    @ResponseBody
    public ServerResponse queryReceiving(HttpServletRequest httpServletRequest) {
        return this.lotteryService.queryReceiving(httpServletRequest);
    }

    /**
     * 设置收货接口
     * @param httpServletRequest
     * @return
     */
    @RequestMapping(value = {"receiving.do"}, method = {RequestMethod.POST})
    @ResponseBody
    public ServerResponse receiving(
            @RequestParam("name") String name,
            @RequestParam("tel") String tel,
            @RequestParam("addressDetail") String addressDetail,
            HttpServletRequest httpServletRequest) {


        return this.lotteryService.receiving(name, tel, addressDetail, httpServletRequest);
    }

    /**
     * 奖品类型为实物的发货接口
     * @param httpServletRequest
     * @return
     */
    @RequestMapping(value = {"addPost.do"}, method = {RequestMethod.POST})
    @ResponseBody
    public ServerResponse addPost(
            @RequestParam("lotteryPrizeId") Integer lotteryPrizeId,
            HttpServletRequest httpServletRequest) {


        return this.lotteryService.addPost(lotteryPrizeId, httpServletRequest);
    }


    /**
     * 用户中奖记录接口
     * @param httpServletRequest
     * @return
     */
    @RequestMapping(value = {"winningRecord.do"}, method = {RequestMethod.POST})
    @ResponseBody
    public ServerResponse winningRecord(
            @RequestParam(name="pageNo", defaultValue="1") Integer pageNum,
            @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
            HttpServletRequest httpServletRequest) {

        return this.lotteryService.winningRecord(pageNum, pageSize, httpServletRequest);
    }

    /**
     * 抽奖个人信息接口
     * @param httpServletRequest
     * @return
     */
    @RequestMapping(value = {"lotteryInfo.do"}, method = {RequestMethod.POST})
    @ResponseBody
    public ServerResponse lotteryInfo(HttpServletRequest httpServletRequest) {

        return this.lotteryService.lotteryInfo(httpServletRequest);
    }


}
